home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 May: Tool Chest / Developer CD Series Tool Chest (Apple Computer)(May 1999).iso / What's New? / • What was new 03⁄99 / Development Kits / USBDDK_1.2d3 / Interfaces / UniversalHIDModule.h < prev    next >
Encoding:
C/C++ Source or Header  |  1999-01-19  |  4.5 KB  |  153 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        UniversalHIDModule.h
  3.  
  4.     Contains:    This describes the interface a higher level part of the OS uses
  5.                 to talk with a UniversalHIDModule, and the way to implement
  6.                 a UniversalHIDModule compliant HID module.
  7.  
  8.      Version:    xxx put version here xxx
  9.  
  10.  
  11. */
  12.  
  13. /* We are not USB specific, but we share many definitions with the USB spec*/
  14. #ifndef __UNIVERSALHIDMODULE__
  15. #define __UNIVERSALHIDMODULE__
  16.  
  17. #ifndef __MACTYPES__
  18. #include <MacTypes.h>
  19. #endif
  20. #ifndef __USB__
  21. #include <USB.h>
  22. #endif
  23.  
  24.  
  25.  
  26. #if PRAGMA_ONCE
  27. #pragma once
  28. #endif
  29.  
  30. #ifdef __cplusplus
  31. extern "C" {
  32. #endif
  33.  
  34. #if PRAGMA_IMPORT
  35. #pragma import on
  36. #endif
  37.  
  38. #if PRAGMA_STRUCT_ALIGN
  39.     #pragma options align=mac68k
  40. #elif PRAGMA_STRUCT_PACKPUSH
  41.     #pragma pack(push, 2)
  42. #elif PRAGMA_STRUCT_PACK
  43.     #pragma pack(2)
  44. #endif
  45.  
  46. typedef UInt32                             UHIDModuleConnectionID;
  47. /* FunctionPtr to be called when inturrupt occurs*/
  48. typedef CALLBACK_API_C( void , UHIDInterruptProcPtr )(void *theData, UInt32 refcon);
  49. /* FunctionPtr definitions for UniversalHIDModule dispatch table*/
  50. typedef CALLBACK_API_C( OSStatus , UHIDGetDeviceInfoProcPtr )(UInt32 inInfoSelector, void *outInfo);
  51. typedef CALLBACK_API_C( OSStatus , UHIDGetHIDDescriptorProcPtr )(UInt32 inDescriptorType, UInt32 inDescriptorIndex, UInt32 *ioBufferSize, void *outBuffer);
  52. typedef CALLBACK_API_C( OSStatus , UHIDClaimDeviceProcPtr )(UHIDModuleConnectionID *outConnectionID, UInt32 reserved);
  53. typedef CALLBACK_API_C( OSStatus , UHIDReleaseDeviceProcPtr )(UHIDModuleConnectionID inConnectionID);
  54. typedef CALLBACK_API_C( OSStatus , UHIDInstallInterruptProcPtr )(UHIDModuleConnectionID inConnectionID, UHIDInterruptProcPtr inInterruptProc, UInt32 inRefcon);
  55. typedef CALLBACK_API_C( OSStatus , UHIDControlDeviceProcPtr )(UHIDModuleConnectionID inConnectionID, UInt32 inControlSelector, void *ioControlData);
  56.  
  57. enum {
  58.     kCurrentDispatchTableVersion = 5,
  59.     kOldestCompatableDispatchTableVersion = 5
  60. };
  61.  
  62. /*
  63.    UHIDModuleDispatchTable is exported by the HIDModule's PEF container
  64.    dispatchTableCurrentVersion is kCurrentDispatchTableVersion
  65.    dispatchTableOldestVersion is kOldestCompatableDispatchTableVersion
  66.           (the oldest built client using this API that this UHIDModule will work with)
  67.    vendorID is who wrote this UniversalHIDModule (hi word of 0 and USB vendorID is valid)
  68. */
  69.  
  70. struct UHIDModuleDispatchTableStruct {
  71.     UInt16                             dispatchTableCurrentVersion;
  72.     UInt16                             dispatchTableOldestVersion;
  73.     UInt32                             vendorID;
  74.     UInt32                             vendorSpecific;
  75.     UInt32                             reserved;
  76.     UHIDGetDeviceInfoProcPtr         pUHIDGetDeviceInfo;
  77.     UHIDClaimDeviceProcPtr             pUHIDClaimDevice;
  78.     UHIDReleaseDeviceProcPtr         pUHIDReleaseDevice;
  79.     UHIDInstallInterruptProcPtr     pUHIDInstallInterrupt;
  80.     UHIDControlDeviceProcPtr         pUHIDControlDevice;
  81.     UHIDGetHIDDescriptorProcPtr     pUHIDGetHIDDescriptor;
  82. };
  83. typedef struct UHIDModuleDispatchTableStruct UHIDModuleDispatchTableStruct;
  84.  
  85. typedef UHIDModuleDispatchTableStruct     UHIDModuleDispatchTable;
  86. typedef UHIDModuleDispatchTableStruct *    UHIDModuleDispatchTablePtr;
  87. /* the prototypes for the actual functions in the UHIDModule follow*/
  88. EXTERN_API_C( OSStatus )
  89. UHIDGetDeviceInfo                (UInt32                 inInfoSelector,
  90.                                  void *                    outInfo);
  91.  
  92. EXTERN_API_C( OSStatus )
  93. UHIDGetHIDDescriptor            (UInt32                 inDescriptorType,
  94.                                  UInt32                 inDescriptorIndex,
  95.                                  UInt32 *                ioBufferSize,
  96.                                  void *                    outBuffer);
  97.  
  98. /* Claim and release are a way to insure that only one client is connected*/
  99. EXTERN_API_C( OSStatus )
  100. UHIDClaimDevice                    (UHIDModuleConnectionID * outConnectionID,
  101.                                  UInt32                 reserved);
  102.  
  103. EXTERN_API_C( OSStatus )
  104. UHIDReleaseDevice                (UHIDModuleConnectionID  inConnectionID);
  105.  
  106. EXTERN_API_C( OSStatus )
  107. UHIDInstallInterrupt            (UHIDModuleConnectionID  inConnectionID,
  108.                                  UHIDInterruptProcPtr     inInterruptProc,
  109.                                  UInt32                 inRefcon);
  110.  
  111. EXTERN_API_C( OSStatus )
  112. UHIDControlDevice                (UHIDModuleConnectionID  inConnectionID,
  113.                                  UInt32                 inControlSelector,
  114.                                  void *                    ioControlData);
  115.  
  116. /* these are the constants to be passed to UHIDControlDevice*/
  117.  
  118. enum {
  119.     kUHIDRemoveInterruptHandle    = 0,
  120.     kUHIDVendorSpecificControlStart = 0x00010000
  121. };
  122.  
  123. /* these are the constants to be passed to UHIDGetDeviceInfo*/
  124.  
  125. enum {
  126.     kUHIDGetVendorID            = 0,
  127.     kUHIDGetProductID            = 1,
  128.     kUHIDGetMaxPacketSize        = 2,
  129.     kUHIDVendorSpecificGetInfoStart = 0x00010000
  130. };
  131.  
  132.  
  133. #if PRAGMA_STRUCT_ALIGN
  134.     #pragma options align=reset
  135. #elif PRAGMA_STRUCT_PACKPUSH
  136.     #pragma pack(pop)
  137. #elif PRAGMA_STRUCT_PACK
  138.     #pragma pack()
  139. #endif
  140.  
  141. #ifdef PRAGMA_IMPORT_OFF
  142. #pragma import off
  143. #elif PRAGMA_IMPORT
  144. #pragma import reset
  145. #endif
  146.  
  147. #ifdef __cplusplus
  148. }
  149. #endif
  150.  
  151. #endif /* __UNIVERSALHIDMODULE__ */
  152.  
  153.